﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RuTracker.Interface;
using RuTracker.MVC.Core;
using RuTrackerLib;
using RuTrackerLib.Tracker;

namespace RuTracker.MVC.Controllers
{
    public class ProcessingController : Controller
    {
        public ActionResult DownloadTorrentFileToDropboxFolder(string id)
        {
            IUserRepository repository = Container.Current.Resolve<IUserRepository>();
            TorrentsLoader loader = Container.Current.Resolve<TorrentsLoader>();

            string url = QueryStringEncryptor.Decrypt(id);
            loader.DownloadTorrent(repository.GetUserStorageInfo(User.Identity.Name), url);

            return RedirectToAction("Tracker", "Default", new {query = id});
        }

    }
}
